<template>
  <div class="box">
    <el-button plain @click="test()" :disabled="buttons_canbeused.delete">删除采购订单</el-button>
    <el-button plain @click="test1()" >改变状态</el-button>
    <el-form
      ref="form"
      :model="submit"
      label-position="left"
      label-width="105px"
      size="mini"
      inline
    >
      <el-form-item label="*供应商" label-width="70px">
        <el-input v-model="submit.name" style="width:200px;"></el-input>
        <el-popover placement="right" width="400" v-model="SupplierListApp.visible">
          <div style="width:400px">
            <el-table
              border
              :data="SupplierListApp.list"
              @row-click="selectSuppliser"
              :stripe="true"
              :header-cell-style="{background:'#e3e5e9',color:'#606266'}"
              :row-style="{height:'5px'}"
              :cell-style="{padding:'5px 0'}"
              tooltip-effect="light"
              highlight-current-row
              style="width: 100%;"
              height="300px"
            >
              <el-table-column prop="code" label="供应商编码" width="95"></el-table-column>
              <el-table-column prop="name" label="供应商名称" width="250"></el-table-column>
            </el-table>
            <div style="width:100px;background:red;margin:3px auto;">
              <el-button type="primary" @click="SureSelectSupplier">确定选择机构</el-button>
            </div>
          </div>
          <el-button slot="reference" @click="SupplierListApp.visible=true">选择</el-button>
        </el-popover>
      </el-form-item>
    </el-form>
    <p>{{submit.name}}</p>
    <el-input v-model="submit.name"></el-input>
    <el-button @click="test()">尝试用对象赋值</el-button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      submit: {
        name: ""
      },
      buttons_canbeused: {
        delete: false
      },
      SupplierListApp: {
        list: [],
        visible: false
      }
    };
  },
  methods: {
    test() {
      let obj = {
        name: "我已经给你赋值新的对象了"
      };
      this.submit = obj;
    },
    test1() {
		this.buttons_canbeused.delete = !this.buttons_canbeused.delete;
	},
    selectSuppliser(Row) {
      this.submit.name = Row.name;
    },
    SureSelectSupplier() {
      this.SupplierListApp.visible = false;
      this.SupplierListApp.datas = JSON.parse(
        JSON.stringify(this.TempApp.supplierTempRow)
      );
    }
  },
  created() {
    this.$http.get("/supplier/list").then(response => {
      this.SupplierListApp.list = response.data;
    });
  }
};
</script>
